﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;

namespace MyPoints.UserControls.Converters
{
  public class PathExistToSolidBrushConverter : IMultiValueConverter
  {
    public object Convert(object [] value, Type targetType, object parameter, CultureInfo culture)
    {      
      SolidColorBrush ret;
      string path = value[0] as string;
      SelectFile.eMode mode = (SelectFile.eMode) value[1];
      bool isValid;
      if (mode == SelectFile.eMode.File)
        isValid = System.IO.File.Exists(path);
      else
        isValid = System.IO.Directory.Exists(path);
      if (isValid)
        ret = new SolidColorBrush(System.Windows.Media.Colors.LightGreen);
      else
        ret = new SolidColorBrush(System.Windows.Media.Color.FromRgb(255, 100, 100));

      return ret;
    }

    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
    {
      throw new NotImplementedException();
    }
  }
}
